﻿using System;
using System.Collections.Generic;
using System.Linq;
using Common.Model;
using Common.util;
using Dapper;

namespace Common.Dao
{
    public class MainTopicDao
    {
        public static List<TopicStockModel> GetAllMainTopicData()
        {
            String sql = @"
            SELECT a.topic_name as TopicName, b.stock_code as StockCode  FROM `main_topic` a 
            inner join main_stocks b 
            on a.topic_name = b.topic_name 
            where a.is_deleted = 0 and b.is_deleted = 0";
            using (var conn = DbUtils.GetHotTopicConnection())
            {
                var rows = conn.Query<TopicStockModel>(sql);
                return rows?.ToList();
            }
        }

        public static List<Topic> GetAllTopics()
        {
            String sql = @"SELECT topic_name as TopicName,merge_name as MergeName FROM `main_topic` where is_deleted = 0";
            using (var conn = DbUtils.GetHotTopicConnection())
            {
                var rows = conn.Query<Topic>(sql);
                return rows?.ToList();
            }
        }

    }
}